/**
 * 大屏controller
 */
package cn.stylefeng.guns.sys.modular.system.controller;

import cn.stylefeng.guns.base.auth.annotion.Permission;
import cn.stylefeng.guns.base.auth.context.LoginContextHolder;
import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.sys.core.auth.cache.SessionManager;
import cn.stylefeng.guns.sys.modular.system.warpper.DeptWrapper;
import cn.stylefeng.roses.core.base.controller.BaseController;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.miot.im.cache.MiotCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 大屏控制器
 */
@Controller
public class BigindexController extends BaseController {


    @Autowired
    private SessionManager sessionManager;

    /**
     * 跳转到 多用户的大屏界面
     * @return
     */
    @RequestMapping(value = "/bigindexmore")
    public String bigindexmore() {

        if (LoginContextHolder.getContext().hasLogin()) {
            return REDIRECT + "/" +"bigindexmore.html";
        } else {
            return "/login.html";
        }

    }


    @RequestMapping(value = "/bigindexone")
    public String bigindexoneGet(Model model) {

        String[] args = new String[]{"cc","bb","aa"};
        model.addAttribute("bigindeonedata", args);
        model.addAttribute("args", args);
        List<String> list = new ArrayList<String>();
        list.add("list_a");
        list.add("list_b");
        list.add("list_c");
        model.addAttribute("lisa", list);

        String[] dataCacheArray = MiotCache.dataCacheArray;

        model.addAttribute("wddata", dataCacheArray[10]); //温度
        model.addAttribute("sddata", dataCacheArray[11]); //湿度
        model.addAttribute("pm25Date", dataCacheArray[12]); //pm25Date
        model.addAttribute("co2Data", dataCacheArray[13]); //co2Data
        model.addAttribute("vocData", dataCacheArray[14]); //vocData

        if (LoginContextHolder.getContext().hasLogin()) {
            return "/bigindex.html";
        } else {
            return "/login.html";
        }
    }

    @RequestMapping(value = "/bigindexonevalue")
    @ResponseBody
    public String[] bigindexoneValue() {

        String[] dataCacheArray = MiotCache.dataCacheArray;

        return  dataCacheArray;
    }

    /**
     * 获取所有部门列表
     *
     * @author fengshuonan
     * @Date 2018/12/23 4:57 PM
     */
    @RequestMapping(value = "/bigindexonedata")
    @Permission
    @ResponseBody
    public Object bigindexonedata() {

        return null;
    }
}